/*
 *  GWPitchedDelayEffect.cpp
 *  GWGlitch
 *
 *  Created by Michael Forrest on 01/03/2008.
 *  Copyright 2008 Grimaceworks. All rights reserved.
 *
 */

#include "GWPitchedDelayEffect.h"

void GWPitchedDelayEffect::Process(const Float32		*inSourceP,
								Float32		*inDestP,  
								UInt32 		inFramesToProcess,  
								UInt32		inNumChannels,  
								bool		&ioSilence){
								
	
	UInt32 nSampleFrames = inFramesToProcess;
	const Float32 *sourceP = inSourceP;
	Float32 *destP = inDestP;
	Float32 delayPitch = kernel->GetParameter(kParam_DelayPitch);
	Float32 feedback = kernel->GetParameter(kParam_DelayFeedback) / 100;
	echo->setDelay(delayPitch);
	echo->setFeedback(feedback);
	//modulator->setFrequency(kernel->GetParameter(kParam_RingModPitch) );

	while (nSampleFrames-- > 0) {
		Float32 inputSample = *sourceP;
		
		sourceP += inNumChannels;	
		
        Float32 outputSample =  echo->tick(inputSample);
		// * gain;
	//	printf("outputSample=%f\n", outputSample);
		//modulator->addTime(1.0);
		
		
		*destP = outputSample;
		destP += inNumChannels;
	}

}
